home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample SMSAM / SampleSMSAM Source / 2020HalfGateway / BufferDescriptor.cp < prev    next >
Encoding:
Text File  |  1995-07-28  |  1.1 KB  |  54 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        BufferDescriptor.cp
  3.  
  4.     Copyright:    © 1991-1994 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Part of the AOCE Sample SMSAM Package.  Consult the license
  8.     which came with this software for your specific legal rights.
  9.  
  10. */
  11.  
  12.  
  13.  
  14. #ifndef __BUFFERDESCRIPTOR__
  15. #include "BufferDescriptor.h"
  16. #endif
  17.  
  18. #ifndef __IOSTREAM__
  19. #include <iostream.h>
  20. #endif
  21.  
  22. #ifndef    __DEBUGGINGGEAR__
  23. #include "DebuggingGear.h"
  24. #endif
  25.  
  26. TMailBuffer::TMailBuffer(long bufferSize) {
  27.     fAllocatedBuffPtrWithNewPtr = true;
  28.     fBuf.dataSize = 0;
  29.     fBuf.buffSize = bufferSize;
  30.     fBuf.buffPtr = FAILNewPtr (bufferSize);
  31. }
  32.  
  33. TMailBuffer::TMailBuffer (long bufferSize, void *buffer, long dataSize) {
  34.     fAllocatedBuffPtrWithNewPtr = false;
  35.     fBuf.dataSize = dataSize;
  36.     fBuf.buffSize = bufferSize;
  37.     fBuf.buffPtr = (Ptr) buffer;
  38. }
  39.  
  40. TMailBuffer::~TMailBuffer () {
  41.     if (fAllocatedBuffPtrWithNewPtr && (fBuf.buffPtr))
  42.         DeallocatePtr(fBuf.buffPtr);
  43. }
  44.  
  45. void TMailBuffer::SetDataSize (long newDataSize) {
  46.     if (newDataSize < 0)
  47.         newDataSize = 0;
  48.     if (newDataSize > BufferSize())
  49.         newDataSize = BufferSize();
  50.  
  51.     fBuf.dataSize = newDataSize;
  52. }
  53.  
  54.